********************************************************************************
* CREATING TABLES    
* File description: Creating table 7, 8, A4.6                         
********************************************************************************

clear all
set more off

use "use/final_consumption", clear


global controls age age2 female educ married children adults lndispinch unemployed
global muni_controls lnp50 share_loweduc share_female share_kids share_married share_selfemployed population lnhouseprice

* Table 7, Panel A

set more off
eststo clear

eststo: areg lnsavings yitz_muni $muni_controls $controls i.year, a(municipality) cluster(municipality) robust

eststo: areg lnsavings yitz_muni $muni_controls $controls i.year if dispinch<=p50, a(municipality) cluster(

eststo: areg lnsavings yitz_muni $muni_controls $controls i.year if dispinch>p50, a(municipality) cluster(municipality) robust


esttab using "out/table7.tex", label replace se 	


* Table 8
gen male=cond(female==0,1,0)


foreach var in female male {

set more off
eststo clear
eststo: areg lnsavings yitz_muni $muni_controls $controls i.year if `var'==1, a(municipality) cluster(municipality) robust

eststo: areg lnsavings yitz_muni $muni_controls $controls i.year if dispinch<=p50 & `var'==1, a(municipality) cluster(municipality) robust

eststo: areg lnsavings yitz_muni $muni_controls $controls i.year if dispinch>p50 & `var'==1 , a(municipality) cluster(municipality) robust


if `var'=="female" {

esttab using "out/table8.tex", label replace se

}
else {
esttab using "out/table8.tex", label append se
}
}

* Table A4.6
eststo clear
eststo: areg lnsavings yitz_muni $muni_controls $controls i.year if female==1 & married==0, a(municipality) cluster(municipality) robust

eststo: areg lnsavings yitz_muni $muni_controls $controls i.year if female==0 & married==0, a(municipality) cluster(municipality) robust

esttab using "out/tableA4_6.tex", label replace se
